<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="../base/base.jspf" %>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="logUserAcc" placeholder="请输入账号" autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="logUserName" placeholder="请输入姓名" autocomplete="off" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">日志类型</label>
                    <div class="layui-input-block">
                        <select name="logType" lay-search>
                            <option placeholder="请选择"></option>
                            <c:forEach var="logType" items="${logTypes}">
                                <option value="${logType.key }">${logType.value }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">记录时间:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="start_time" id="start_time" placeholder="请输入开始时间" autocomplete="off"
                               readonly="readonly" class="layui-input"/>
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline">
                        <input type="text" name="end_time" id="end_time" placeholder="请输入结束时间" autocomplete="off"
                               readonly="readonly" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn" type="button" lay-submit lay-filter="lay-log-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <script type="text/html" id="toolbar-logListPage-log">
                <div class="layui-btn-container"></div>
            </script>
            <table id="log-page-list" lay-filter="LAY-user-manage"></table>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.config({
        base: "${ctx}/static/framework/layuiadmin/" //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use(["index", "table", "form", "laydate"], function () {
        var table = layui.table, form = layui.form, laydate = layui.laydate;
        table.render({
            elem: "#log-page-list",
            url: "${ctx}/log/getLogList",
            method: "post",
            toolbar: "#toolbar-logListPage-log",
            defaultToolbar: ["filter", "print"],
            height: "full-170",//自己根据表格上方和下方的高度减去对应数值，保证侧边无滚动条即可
            cols: [[{
                field: "logAssociationId",
                title: "协会",
                sort: true,
                width:100,
                templet: function (data) {
                    return xiehuiTrans(data.logAssociationId);
                }
            }, {
                field: "logUserAcc",
                title: "账号",
                sort: true,
                width:100
            }, {
                field: "logUserName",
                title: "姓名",
                width:120
            }, {
                field: "logPhoneNumber",
                title: "联系电话",
                width:150
            }, {
                field: "logIp",
                title: "登录IP",
                width:120
            }, {
                field: "logMac",
                title: "登录mac地址",
                width:180
            }, {
                field: "logType",
                title: "日志类型",
                templet: function (data) {
                    return enumTrans("logType", data.logType);
                }
            }, {
                field: "logSingTime",
                title: "记录时间",
                width:180,
                templet: function (data) {
                    return parseToDate(data.logSingTime).format("yyyy-MM-dd hh:mm:ss");
                }
            }, {
                field: "logContent",
                title: "日志内容"
            }]],
            page: true,
            limit: 20,
            limits: [20, 50, 100],
            text: {
                none: "暂无相关数据"
            }
        });

        form.on("submit(lay-log-front-search)", function (data) {
            table.reload("log-page-list", {
                where: data.field,
                page: {curr: 1}
            });
        });

        laydate.render({
            elem: "#start_time",
            type: "datetime",
            format: "yyyy-MM-dd HH:mm:ss"
        });

        laydate.render({
            elem: "#end_time",
            type: "datetime",
            format: "yyyy-MM-dd HH:mm:ss"
        });
    });
</script>